import 'dart:async';

import '../ui/index.dart';

///单次操作过滤
mixin OnceClick {
  bool _finish = true;

  void startOnce(Future Function() task, {bool clickMaskDismiss = false}) {
    if (!_finish) {
      Loading.show(clickMaskDismiss: clickMaskDismiss);
      return;
    }
    _finish = false;
    Loading.show(clickMaskDismiss: clickMaskDismiss);
    Completer()
      ..complete(task())
      ..future.whenComplete(() => _finish = true);
  }
}
